//
//  WithDrawHistoryTableViewCell.m
//  lhpc_manager
//
//  Created by 李英杰 on 2017/9/6.
//  Copyright © 2017年 zhaoyongjie. All rights reserved.
//

#import "WithDrawHistoryTableViewCell.h"

@interface WithDrawHistoryTableViewCell ()

@property (nonatomic, strong) UIView * backView;
@property (nonatomic, strong) UILabel * titleLabel;
@property (nonatomic, strong) UILabel * timeLabel;
@property (nonatomic, strong) UILabel * moneyLabel;
@property (nonatomic, strong) UILabel * etaTimeLabel;

@end

@implementation WithDrawHistoryTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatMainView];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = BACKCOLOR;
    }
    return self;
}

-(void)setWithDrawHistoryValue:(WithDrawHistoryModel *)model{
    
    
    self.titleLabel.text = model.title;
    self.timeLabel.text = model.time;
    self.moneyLabel.text = [NSString stringWithFormat:@"+%.2f元",model.cash];
    
    if (model.status) {
        self.moneyLabel.textColor = BLACKCOLOR;
        
    }else{
        self.moneyLabel.textColor = ORANGCOLOR;
    }
    
}

-(void)creatMainView{
    
    [self.contentView addSubview:self.backView];
    [self.backView addSubview:self.titleLabel];
    [self.backView addSubview:self.timeLabel];
    [self.backView addSubview:self.moneyLabel];
//    [self.backView addSubview:self.etaTimeLabel];
    
    [self updateConstraints];
    
}

-(void)updateConstraints{
    [super updateConstraints];
    
    [self.backView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.left.right.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView).offset(-1);
    }];
    
    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.bottom.equalTo(self.backView.mas_centerY).offset(-3);
        make.left.equalTo(self.backView).offset(15);
        
    }];
    
    [self.timeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.backView.mas_centerY).offset(3);
        make.left.equalTo(self.titleLabel);
        
    }];
    
    [self.moneyLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.equalTo(self.backView);
        make.right.equalTo(self.backView).offset(-15);
        
    }];
    
}


-(UIView *)backView{
    if (!_backView) {
        _backView = [[UIView alloc]init];
        _backView.backgroundColor = [UIColor whiteColor];
    }
    return _backView;
}


-(UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.textColor = BLACKCOLOR;
        _titleLabel.font = [UIFont systemFontOfSize:15];
    }
    return _titleLabel;
}

-(UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc]init];
        _timeLabel.textColor = GRAYCOLOR;
        _timeLabel.font = [UIFont systemFontOfSize:14];
    }
    return _timeLabel;
}

-(UILabel *)moneyLabel{
    if (!_moneyLabel) {
        _moneyLabel = [[UILabel alloc]init];
//        _moneyLabel.textColor = ORANGCOLOR;
        _moneyLabel.font = [UIFont systemFontOfSize:18];
    }
    return _moneyLabel;
}

-(UILabel *)etaTimeLabel{
    if (!_etaTimeLabel) {
        _etaTimeLabel = [[UILabel alloc]init];
        
    }
    return _etaTimeLabel;
}

@end
